<% # determine which mode this partial currently works in: inbox or outbox; -%>
<% # certain feature will only be visible in the inbox -%>
<% opened_from_inbox = (@message_folder == "inbox") -%>


<h1>View Message: <%=h @message.subject %></h1>

<ul class="buttons">
	<% if opened_from_inbox -%>
	  <li><%= icon('message', messages_path, "Return to Inbox", nil, 'Return to Inbox') -%></li>
  	<li><%= icon('reply', url_for(:controller => :messages, :action => :new, :reply_id => @message.id), nil, nil, 'Reply to this Message') %></li>
  <% else -%>
	  <li><%= icon('messages_outbox_no_arrow', sent_messages_path, "Return to Sent Messages", nil, 'Return to Sent Messages') -%></li>
  <% end -%>
	<li>
<%= icon "destroy", message_path(@message), "Delete this Message", { :confirm => 'Are you sure?', :method => :delete }, "Delete this Message" -%>
	</li>
</ul>

<% # this makes sure that the message is a reply to something, and that the original message still exists -%>
<% if @message.reply? && @message.reply_to && !@message.reply_to.deleted_by_sender %>
  <br/>
  <p class="box_infotext">
    <b>This message is a reply to:</b> <%= link_to h(@message.reply_to.subject), message_path(@message.reply_to) %>
  </p>
<% end %>

<br/>

<div class="message_box">
	<div style="float: left; text-align: center;">
		<b>From </b>
		<%= render :partial => "users/avatar", :locals => { :user => @message.from, :size => 50 } %>
	</div>
	
	<div style="float: left; text-align: center; margin-left: 3em;">
		<b>To </b>
		<%= render :partial => "users/avatar", :locals => { :user => @message.to, :size => 50 } %>
	</div>
	
	<div style="float: left; margin-left: 3em; width: 470px;">
		<p><b>Subject</b></p>
		<p class="subject">
			<%=h @message.subject %>
		</p>
		<p><b>Sent: </b><%=@message.created_at %></p>
	</div>
	
	<div class="clearer">&nbsp;</div>
	
	<br/>
	
	<p><b>Message</b></p>
	<div class="message">
		<% unless @message.body.blank? %>
			<%= @message.body %>
		<% else %>
			<p class="none_text">No message body</p>
		<% end %>
	</div>
</div>
